package ro.imc.rest.client.display.components;

import ro.imc.rest.shared.dto.LearningObject;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Image;

public class LearningObjectFrom extends Composite  {

	private static LearningObjectFromUiBinder uiBinder = GWT
			.create(LearningObjectFromUiBinder.class);
	@UiField AbsolutePanel learningObjectUi;
	@UiField Label startDate;
	@UiField Image objImg;
	@UiField Label strObjName;
	@UiField Label sdLabel;
	@UiField Label edLabel;
	@UiField Label endDate;

	interface LearningObjectFromUiBinder extends
			UiBinder<Widget, LearningObjectFrom> {
	}

	public LearningObjectFrom(LearningObject object) {
		initWidget(uiBinder.createAndBindUi(this));
		if(!object.isFolder()) {
			setFieldsVisible();
			startDate.setText(object.getStartDate());
			endDate.setText(object.getEndDate());
		}
		strObjName.setText(object.getName());
		objImg.setUrl(object.getIconPath());
		
	}
	
	private void setFieldsVisible() {
		sdLabel.setVisible(true);
		edLabel.setVisible(true);
		startDate.setVisible(true);
		endDate.setVisible(true);
	}



}
